﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MoneyWentWhere.Model;

namespace MoneyWentWhere.Test
{    
    public static class TestExtensionMethods
    {
        // Random
        public static DateTime NextDate(this Random r)
        {
            const int maxDays = 200 * 12 * 365;
            return DateTime.MinValue.AddDays(r.Next(maxDays));
        }

        /// <summary>
        /// Create a trasnaction list with random transactions
        /// </summary>
        /// <param name="r"></param>
        /// <param name="txCount"></param>
        /// <returns></returns>
        public static TransactionList NextTransactionList(this Random r, int txCount)
        {
            TransactionList tl = new TransactionList();
            for (int i = 0; i < txCount; i++)
            {
                Transaction tx = new Transaction() { Date = r.NextDate() };
                int index = r.Next(tl.Count + 1);
                tl.Insert(index, tx);
            }
            return tl;
        }

    }
}
